<template>
  <BaseCard class="action-list" :bg="false" :gap="0">
    <template v-for="item of list" :key="item.title">
      <VanCell
        :icon="item.icon"
        :title="item.title"
        is-link
        :clickable="false"
        :border="false"
        v-to-build.check="!item.link"
        @click="onClickItem(item)"
      />
    </template>
  </BaseCard>
</template>

<script setup>
import { ref, computed, watch } from "vue";
import { useRouter } from "vue-router";
import { useLoginStore } from "@/stores/auth.js";

const list = ref([
  {
    title: "我的钱包",
    icon: "balance-o",
    link: {
      name: "wallet",
    },
  },
  {
    title: "我的订单",
    icon: "orders-o",
    link: {
      name: "myOrder",
    },
  },
  {
    title: "我的仓库",
    icon: "bag-o",
    link: {
      name: "cloudStore",
    },
  },
  {
    title: "收货信息",
    icon: "wap-home-o",
    link: {
      name: "address",
    },
  },
  {
    title: "优惠信息",
    icon: "coupon-o",
  },
  {
    title: "收藏商品",
    icon: "goods-collect-o",
  },
  {
    title: "用户设置",
    icon: "setting-o",
    link: {
      name: "setting",
    },
  },
  {
    title: "合伙人招募",
    icon: "award-o",
    link: {
      name: "hhrAgree",
    },
    // link: {
    //   name: "about-us",
    // },
  },

  {
    title: "联系我们",
    icon: "phone-circle-o",
    // link: {
    //   name: "about-us",
    // },
  },
]);

const { getUserInfo } = useLoginStore();
const userInfo = getUserInfo();

const hasInvitation = computed(() => {
  return userInfo.value?.invitationCode == "868686";
});

watch(
  hasInvitation,
  () => {
    if (hasInvitation.value) {
      // list.value.push({
      //   title: "充值",
      //   icon: "gold-coin-o",
      //   link: {
      //     name: "charge",
      //   },
      // });
    }
  },
  {
    immediate: true,
  }
);

const router = useRouter();
const onClickItem = (item) => {
  item.link && router.push(item.link);
};
</script>

<style lang="scss" scoped>
.action-list {
  --van-cell-background: transparent;
  --van-cell-font-size: var(--dx-font-size-md);
  --van-cell-horizontal-padding: var(--dx-gap-xs);
}
</style>
